package com.sinosoft.dsp.component.bpm.facade.engine;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.NoneScoped;

import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.history.HistoryTask;

import com.sinosoft.dsp.component.bpm.util.JbpmConfig;
import com.sinosoft.dsp.platform.utils.SinoManagedBean;

/**
 * 流程管理服务门面
 * 
 * @author lichanghao
 * @since 2011-2-2 上午07:05:28
 */
@ManagedBean(name = "processManageFacade")
@NoneScoped
public class ProcessManageFacade {

	/**
	 * 根据状态去查询流程实例的历史日志
	 * 
	 * @param state
	 *            流程实例的状态（包括已完成的，挂起的等等）
	 * @return List 历史流程实例列表
	 */
	public List<HistoryProcessInstance> findHistProcessInstanceByState(
			String state) {
		JbpmConfig jbpmConfig = SinoManagedBean.findBean("jbpmConfig");
		List<HistoryProcessInstance> histProcessInstanceList = jbpmConfig
				.getHistoryService().createHistoryProcessInstanceQuery().state(
						state).list();
		return histProcessInstanceList;
	}

	/**
	 * 根据状态去查询流程任务的历史日志
	 * 
	 * @param state
	 *            任务的状态
	 * @return List 历史流程实例任务的列表
	 */
	public List<HistoryTask> findHistTaskOfState(String state) {
		JbpmConfig jbpmConfig = SinoManagedBean.findBean("jbpmConfig");
		List<HistoryTask> histProcessInstanceList = jbpmConfig
				.getHistoryService().createHistoryTaskQuery().state(state)
				.list();
		return null;
	}

}
